<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ include file="/pages/login/common.jsp" %>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content="B2B电商平台" name="description"/>
<meta content="B2B电商平台" name="keyword"/>

<title>B2B电商平台.店铺宣传信息申请</title>
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/style.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/btn.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/themes.css" />
<link rel="stylesheet" href="<%=path%>/include/JQuery zTree v3.4/css/demo.css">
<link rel="stylesheet" href="<%=path%>/include/JQuery zTree v3.4/css/zTreeStyle/zTreeStyle.css">
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/register_icss.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/sweetalert/sweetalert.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/mmt_trading.css" />

<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>
<script type="text/javascript" src="<%=path%>/include/JQuery zTree v3.4/js/jquery.ztree.core-3.4.js"></script>
<script type="text/javascript" src="<%=path%>/include/JQuery zTree v3.4/js/jquery.ztree.excheck-3.4.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
<script type="text/javascript" src="<%=path %>/include/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/sweetalert/sweetalert-dev.js"></script>
<script src="<%=path%>/include/DatePicker/WdatePicker.js" charset="UTF-8" type="text/javascript"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.shop.application.js"></script>

	<link rel="stylesheet" href="<%=path%>/include/layui/css/layui.css"  media="all">
    <script type="text/javascript" src="<%=path %>/include/layui/lay/dest/layui.all.js" charset="utf-8"></script>

<style type="text/css">
body{}
table{border-collapse: collapse;}
tr{ 
    display:block; /*将tr设置为块体元素*/ 
    margin:10px;  /*设置tr间距为2px*/ 
    width:100%;
}
td{padding:5px;height:30px; line-height:30px;}
.td1{
	width:100px;
	font-size:14px;
	text-align:right;
	vertical-align: middle;
}
.input1{
	width:300px;
	height:30px;
	line-height:30px;
	vertical-align:middle;
	float:left;
}
button{
    width:44px;
    height:24px;
    line-height:24px;   
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: 0 -203px;
    border:0;
    cursor:pointer;
    font: 12px/1.5 arial,tahoma,\5b8b\4f53;
    margin: 0 0 0 5px;
    outline:none;
    background-image: url('<%=path%>/include/css/img/xs_bgx.png');   
}
.promptBox{display:inline-block;height:30px;padding-left:5px;width:200px;white-space:nowrap; z-index:50; position:relative;}
.tips-errow{background-position:-296px -22px;color:#f52c2c;}
.tips-ok{background-position:-296px 14px;color:#666;}
.tipsCur{background-position:-296px -55px;color:#666;}
.approveDiv{width:100%;height:23px;margin:0 20px;;padding:15px 0 10px 0;border-bottom: 1px solid #ADADAD;color:blue;}
</style>
<script type="text/javascript">

function _checkAllReady(){
	var result = true;
	jQuery(".rightTd input").each(function(index){
		if(jQuery(this).val()=="" && (jQuery(this).attr("name")=="citySel" || jQuery(this).attr("name")=="shopArea") ){
			result = false;
			jQuery(this).nextAll("div").find(".tips-ok").hide();
			jQuery(this).nextAll("div").find(".tips-errow").hide();
			jQuery(this).nextAll("div").find(".tipsCur").show();
		}
		if(this.name!='file'){
			if(jQuery(this).val()=="" && jQuery(this).attr("name")!="idcardF" 
					&& jQuery(this).attr("name")!="idcardB" && jQuery(this).attr("name")!="businessLicense"){
				result = false;
				jQuery(this).next("div").find(".tips-ok").hide();
				jQuery(this).next("div").find(".tips-errow").hide();
				jQuery(this).next("div").find(".tipsCur").show();
			}else if(jQuery(this).val()=="" && jQuery(this).attr("name")!="idcardF" 
					&& jQuery(this).attr("name")!="idcardB" && jQuery(this).attr("name")!="businessLicense"){
				console.log(33);
				result = false;
				jQuery(this).parent().nextAll().find(".tips-ok").hide();
				jQuery(this).parent().nextAll().find(".tips-errow").hide();
				jQuery(this).parent().nextAll().find(".tipsCur").show();
			}
		}
	});
	jQuery(".rightTd textarea").each(function(index){
		if(jQuery(this).val()==""){
			result = false;
			jQuery(this).next("div").find(".tips-ok").hide();
			jQuery(this).next("div").find(".tips-errow").hide();
			jQuery(this).next("div").find(".tipsCur").show();
		}
	});
	jQuery(".rightTd select").each(function(index){
		if(jQuery(this).val()==""){
			result = false;
			jQuery(this).nextAll("div").find(".tips-ok").hide();
			jQuery(this).nextAll("div").find(".tips-errow").hide();
			jQuery(this).nextAll("div").find(".tipsCur").show();
		}
	});
	return result;
}
	
	//保存宣传信息
	function applyHomeDisplay(){
		var uuid=$("#uuid").val();
		if(_checkAllReady() && uuid==""){//初次申请
			parent.swal({
                        title: "店铺宣传申请",
                        text: "确认提交申请信息吗？",
                        type: "info",
                        showConfirmButton:true,  
                        showCancelButton: true,
                        cancelButtonText: "取消",
                        closeOnConfirm: true,
                        animation: "slide-from-top",
                    }, function(inputValue) {
                    	if(inputValue){
                    			$.ajax({
									url:"<%=path%>/applyHomeDisplay/save.do",
									data:{
										applyName:$("#applyName").val(),
										content:$("#content").val(),
										picUrl:$("#picUrl").val(),
										begDate:$("#begDate").val(),
										endDate:$("#endDate").val(),
										type:$("#type").val()
				  					},
									type:"post",
									dataType:"text",
									success:function(result){
				  						if(result=="保存成功"){
                    						parent.swal("保存信息成功!");
                						}
				  						_goBack();
									}
								});
                    	}
                    });
			
		}else if(_checkAllReady() && uuid!=""){//修改
			parent.swal({
                        title: "店铺宣传申请",
                        text: "确认修改宣传信息吗？",
                        type: "info",
                        showConfirmButton:true,  
                        showCancelButton: true,
                        cancelButtonText: "取消",
                        closeOnConfirm: true,
                        animation: "slide-from-top",
                    }, function(inputValue) {
                    	if(inputValue){
                    			$.ajax({
									url:"<%=path%>/applyHomeDisplay/save.do",
									data:{
										applyName:$("#applyName").val(),
										content:$("#content").val(),
										picUrl:$("#picUrl").val(),
										begDate:$("#begDate").val(),
										endDate:$("#endDate").val(),
				  						type:$("#type").val(),
				  						uuid:$("#uuid").val()
				  					},
				  					dataType:"text",
									type:"post",
									success:function(result){
				  						if(result=="保存成功"){
				  							parent.swal("申请成功!");
                						}
				  						//window.location.reload();
				  						_goBack();
									}
								});
                    	}
                    });
		}
		
	}
	
	//返回店铺信息
	function returnShopInfo(){
		window.location.href="<%=path%>/storeApplyAction/toStoreInfo.do?shopId="+$("#shopId").val();
	
	}
	
	//再次申请
	function applyAgain(){
		parent.swal({
                   title: "店铺宣传申请",
                   text: "确认提交信息吗？",
                   type: "info",
                   showConfirmButton:true,  
                   showCancelButton: true,
                   cancelButtonText: "取消",
                   closeOnConfirm: true,
                   animation: "slide-from-top",
               }, function(inputValue) {
               	if(inputValue){
               			$.ajax({
				url:"<%=path%>/applyHomeDisplay/save.do",
				data:{
					applyName:$("#applyName").val(),
					content:$("#content").val(),
					picUrl:$("#picUrl").val(),
					begDate:$("#begDate").val(),
					endDate:$("#endDate").val(),
 						type:$("#type").val(),
 						uuid:$("#uuid").val()
 					},
				type:"post",
				dataType:"text",
				success:function(result){
       						if(result=="保存成功"){
           						parent.swal("申请成功!");
       						}
       						_goBack();
				}
			});
       	}
       });
	}


	function _goBack(){
		var applyName = $("#applyName").val();
		var begDate = $("#begDate").val();
		var endDate = $("#endDate").val();
		location.href="<%=path%>/applyHomeDisplay/toApplyHomeDisplayListPage.do?begDate="+begDate+"&endDate="+endDate+"&applyName="+escape(escape(applyName));
	}

</script>
</head>
<body class="theme-red" data-theme="theme-red" style="height: 70%">
	<div id="contentDiv" style="width:99%;padding:4px;" >
		<div style="width:100%;height:30px;border-bottom:1px solid #ADADAD;">
			<div class="toptil">店铺宣传信息申请</div>
		</div>
		<form id="fm" name="fm" class="form-horizontal form-validate" method="post" action="" novalidate="novalidate">
			<input type="hidden" id="uuid" name="uuid" value="${bean.APPLICATION_UUID }">
			<input type="hidden" id="type" name="type" value="${type }">
			<input type="hidden" id="shopId" name="shopId" value="${shopId }">
			<input type="hidden" id="curPath" name="curPath" value="<%=path %>">
			<div style="width:100%;margin-top:20px;margin-left:10px;">
				<table style="width:100%;">
					<tr>
						<td class="td1"  nowrap>宣传名称：</td>
						<td class="rightTd" nowrap>
							<input type="text" class="input1" id="applyName" name="applyName" value="${bean.APPLICATION_NAME}" >
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请输入宣传名称</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请输入宣传名称</div>
		                   	</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap>宣传内容：</td>
						<td class="rightTd" nowrap>
							<input class="input1" id="content" name="content" value="${bean.APPLICATION_CONTENT }" >
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请输入宣传内容</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请输入宣传内容</div>
		                   	</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">宣传图片：</td>
						<td class="rightTd" nowrap>
							<div id="applicationPicDiv" style="float:left;text-align:center;">
								<div id="imgDiv3" style="margin-bottom:10px;">
									<img src="${bean.APPLICATION_PIC }" onerror="javascript:this.src='<%=path%>/download/error/nopicture.jpg';"
										id="imgView3" style="height: 120px; width: 300px;">
								</div>
								<div id="file1" class="site-demo-upbar" style="">
								    <input type="file" name="file" class="layui-upload-file" id="test">
								</div>
							</div>
							<input id="picUrl" name="picUrl" type="hidden" value="${bean.APPLICATION_PIC }" >
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请上传宣传图片</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请上传宣传图片</div>
		                   	</div>	
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">开始时间：</td>
						<td class="rightTd" nowrap>
							<input type="text" id="begDate" name="begDate" 
							    	style="width:200px;height:30px;line-height:30px;vertical-align:middle;float:left;" 
							    	onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',position:{left:138.5,top:139}})" class="Wdate" 
							    	value="${bean.BEG_TIME }" />
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请输入开始时间</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请输入开始时间</div>
		                   	</div>	
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">结束时间：</td>
						<td class="rightTd" nowrap>
							<input type="text" id="endDate" name="endDate" 
							    	style="width:200px;height:30px;line-height:30px;vertical-align:middle;float:left;" 
							    	onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'#F{$dp.$D(\'begDate\')}',position:{left:138.5,top:189}})" 
							    	class="Wdate" value="${bean.END_TIME }"/>
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请输入结束时间</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请输入结束时间</div>
		                   	</div>	
						</td>
					</tr>
					<c:if test="${bean.APPLICATION_STATUS != null or bean.APPLICATION_STATUS != ''}">
					<tr style="display: none;">
						<td class="td1" nowrap style="vertical-align:top;">审核状态：</td>
						<td class="rightTd" nowrap>${bean.STATUS }</td>
					</tr>
					</c:if>
					<tr>
						<td class="td1">&nbsp;</td>
						<td class="rightTd">
							<c:choose>
								<c:when test="${bean.APPLICATION_STATUS=='0'}">
								    <button  type="button" onclick="applyHomeDisplay();">保存</button>
								</c:when>
								<c:when test="${bean.APPLICATION_STATUS=='2'}">
								    <button  type="button" style="width:66px;background-size:180px 458px; " onclick="applyAgain();">再次申请</button>
								</c:when>
								<c:otherwise>
									<button  type="button" onclick="applyHomeDisplay();">申请</button>
								</c:otherwise>
							</c:choose>
							<button  type="button" onclick="returnShopInfo();">返回</button>
						</td>
					</tr>
				</table>
			</div>
		</form>
	</div>
</body>
 <script type="text/javascript">
layui.use('upload', function(){
	 layui.upload({
	  	url: '<%=path%>/upload/uploadPic'
	   	,elem: '#test' //指定原始元素，默认直接查找class="layui-upload-file"
	    //,method: 'post' //上传接口的http类型
	    ,success: function(res){
			
			$("#picUrl").val(res.url);
			$("#imgView3").attr("src", res.url);
			if($.trim($("#shopPic").val()) != ''){
				$("#applicationPicDiv").nextAll('div').find(".tips-errow").hide();
				$("#applicationPicDiv").nextAll('div').find(".tipsCur").hide();
				$("#applicationPicDiv").nextAll('div').find(".tips-ok").show();
			}
	    }
	 });
});
</script>
</html>
